Assignemnt #44 and Fourty-first Program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: fourty-first Program
///File name: FourtfProg.java
///Date Finished:10/14/2015
import java.util.Scanner;
public class FourtfProg
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String answer, answer_2, animal, vegetable, mineral;
System.out.println( "TWO QUESTIONS!" );
System.out.println( "Think of an object, and i'll try to guess it." );
System.out.println( "Question 1: Is it an animal, vegetable, or mineral?" );
System.out.print( "> " );
answer = keyboard.next();
if ( answer.equals("animal") )
{
System.out.println( "Question 2: Is it bigger than a bread box?" );
System.out.print( "> " );
answer_2 = keyboard.next();
if ( answer_2.equals("yes") )
{
System.out.println( "My guess is that you are thinking of a panda." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
else if ( answer_2.equals("no") )
{
System.out.println( "My guess is that you are thinking of a mouse." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
}
else if ( answer.equals("vegetable") )
{
System.out.println( "Question 2: Is it bigger than a bread box?" );
System.out.print( "> " );
answer_2 = keyboard.next();
if ( answer_2.equals("yes") )
{
System.out.println( "Question 2: Is it bigger than a bread box?" );
System.out.print( "> " );
answer_2 = keyboard.next();
System.out.println( "My guess is that you are thinking of a pumpkin." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
else if ( answer_2.equals("no") )
{
System.out.println( "My guess is that you are thinking of a carrot." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
}
else if ( answer.equals("mineral") )
{
System.out.println( "Question 2: Is it bigger than a bread box?" );
System.out.print( "> " );
answer_2 = keyboard.next();
if ( answer_2.equals("yes") )
{
System.out.println( "My guess is that you are thinking of a rock." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
else if ( answer_2.equals("no") )
{
System.out.println( "My guess is that you are thinking of a truck." );
System.out.println( "I would ask you if i'm right, but I don't actually care." );
}
}
}
}
Picture of the output